package org.gw.building.util;

import org.springframework.format.Formatter;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.format.datetime.DateTimeFormatAnnotationFormatterFactory;

import java.util.Date;

public class ExtendDateTimeFormatAnnotationFormatterFactory extends DateTimeFormatAnnotationFormatterFactory {
	@Override
	protected Formatter<Date> getFormatter(DateTimeFormat annotation, Class<?> fieldType) {
		MillsecondsDateFormatter formatter = new MillsecondsDateFormatter();
		formatter.setStylePattern(resolveEmbeddedValue(annotation.style()));
		formatter.setIso(annotation.iso());
		formatter.setPattern(resolveEmbeddedValue(annotation.pattern()));
		return formatter;
	}
}
